package 面向对象高级.抽象类和抽象方法;

public abstract class Employee {
    /**
     * 编写一个Employee类，声明为抽象类，包含如下三个属性：name，id，salary。提供必要的构造器和抽象方法：work()。
     * 对于Manager类来说，他既是员工，还具有奖金(bonus)的属性。
     * 请使用继承的思想，设计CommonEmployee类和Manager类，要求类中提供必要的方法进行属性访问。
     */
    String name;
    int id;
    int salary;

    public Employee() {
    }

    public Employee(String name, int id, int salary) {
        this.name = name;
        this.id = id;
        this.salary = salary;
    }
    //抽象的方法
    public abstract void work();
}

 class Manager extends Employee {
    int bonus;

     public Manager(int bonus) {
         this.bonus = bonus;
     }

     public Manager(String name, int id, int salary, int bonus) {
         super(name, id, salary);
         this.bonus = bonus;
     }

     @Override
    public void work() {
        System.out.println("我首先是一个员工，其次才是一个经理");
    }

     @Override
     public String toString() {
         return "Manager{" +
                 "name='" + name + '\'' +
                 ", id=" + id +
                 ", salary=" + salary +
                 ", bonus=" + bonus +
                 '}';
     }
 }
class CommonEmployee extends Employee{

     public CommonEmployee() {
     }

     public CommonEmployee(String name, int id, int salary) {
         super(name, id, salary);
     }

    @Override
    public void work() {
        System.out.println("我是一个普通员工");
    }

    @Override
    public String toString() {
        return "CommonEmployee{" +
                "name='" + name + '\'' +
                ", id=" + id +
                ", salary=" + salary +
                '}';
    }
}

class EmployeeTest{
    public static void main(String[] args) {
        Manager manager = new Manager("张三",1,5000,2000);
        System.out.println(manager);
        CommonEmployee commonEmployee = new CommonEmployee("李四",2,4000);
        System.out.println(commonEmployee);
    }
}
